#pragma once
DEF_EVT_EXT(EventJsonObjectLButtonDown, EVT_EXTERNAL_BEGIN + 7001, {
});
DEF_EVT_EXT(EventJsonObjectLBDBClk, EVT_EXTERNAL_BEGIN + 7002, {
});

class CJsonObject : public SWindow
{
	DEF_SOBJECT(SWindow, L"json_object")
public:
	CJsonObject(void);
	~CJsonObject(void);

protected:
	LRESULT OnCreate(LPVOID);
	void OnPaint(IRenderTarget* pRT);

	void OnLButtonDown(UINT nFlags, SOUI::CPoint point);
	void OnLButtonUp(UINT nFlags, SOUI::CPoint point);
	void OnLButtonDblClk(UINT nFlags, SOUI::CPoint point);
	void OnMouseMove(UINT nFlags, SOUI::CPoint point);

protected:
	SOUI_MSG_MAP_BEGIN()
		MSG_WM_CREATE(OnCreate)
		MSG_WM_PAINT_EX(OnPaint)

		MSG_WM_LBUTTONDOWN(OnLButtonDown)
		MSG_WM_LBUTTONUP(OnLButtonUp)
		MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk)
		MSG_WM_MOUSEMOVE(OnMouseMove)
		SOUI_MSG_MAP_END()

public:
	SOUI::CPoint m_ptLT;
	int		m_nObjIndex;
private:
	bool	m_bSelected;
	bool	m_bMove;
	SOUI::CPoint	m_ptDown;
	std::vector<SWindow*>	m_vecChildren;
	SWindow* m_pObjParent;

	SStringW	m_sstrKey;
	SStringW	m_sstrValue;
public:
	void SetSelect(bool bSelect);

	void setObjParent(SWindow* pParent);
	SWindow* getObjParent();

	void addRootChild(SWindow* pWindow);
	std::vector<SWindow*> getRootChildren();

	void SetKey(SStringW& sstrKey);
	void SetValue(SStringW& sstrValue);
	SStringW GetKey();
	SStringW GetValue();
};

